const { ccclass, property } = cc._decorator;

export default function Singlelon<T>() {
    class Singlelon {
        private static _instance: Singlelon = null;
        static get instance() {
            if (!Singlelon._instance) {
                Singlelon._instance = new this();
                Singlelon._instance._init();
            }
            return <T>Singlelon._instance;
        }

        static release() {
            Singlelon._instance = null;
        }
        protected _init() { }
    }
    return Singlelon;
}


